import { actionType } from './index'
import axios from 'axios'
export const setHomeData = (data = {}) => ({
  type: actionType.SET_HOME_LIST,
  data
})

export const getHomeData = (params) => {
  return (dispatch) => {
    params = Object.assign(params, {pageSize: 10})
    axios.get('https://www.fastmock.site/mock/117dfab41e7433b4719b831059118248/react_jianshu/api/getHome', { params }).then((response) => {
      if (!response.data.success) {
        return false
      }
      let data = response.data.data
      dispatch(setHomeData(data))
    })
  }
}

export const changeScrollShow = (data) => ({
  type: actionType.CHANGE_SHOW_BACK,
  data
})